import useUserStore from '@/stores'
import axios, { type InternalAxiosRequestConfig } from 'axios'
axios.defaults.baseURL = 'https://vue.ruoyi.vip/prod-api'

axios.interceptors.request.use(
  (config: InternalAxiosRequestConfig) => {
    if (config.headers) {
      const store = useUserStore()
      config.headers.Authorization = `Bearer ${store.$state.token}`
    }
    return config
  },
  (error) => {
    return Promise.reject(error)
  }
)
